#include "correcttime.h"
#include "ProtocalIdentifier.h"
#include "NetworkCommonFunction.h"

#include <QDateTime>

CorrectTime::CorrectTime():
		SenderCommand(GetProtocalIdentifier("CorrectTime"))
{
}

void CorrectTime::constructCommandData(QByteArray &commandData)
{
	unsigned long commandType = m_CommandType;
	unsigned long commandLength;

	QDateTime dateTime = QDateTime::currentDateTime();
	QString timeString= dateTime.toString("yyyy-MM-dd hh:mm:ss");

	commandLength = timeString.length();

	commandData.append(FBtoNetworkCharP(commandType),4);
	commandData.append(FBtoNetworkCharP(commandLength), 4);
	commandData.append(timeString);
}
